﻿using System;
using System.Collections.Generic;
using System.IO;

using System.Text;
using System.Xml.XPath;

namespace Transformer.iHunter
{

    /// <summary>
    /// Presents the interface of a channel
    /// </summary>
    public interface IChannel: IDisposable
    {

        /// <summary>
        /// Downloads the messages.
        /// </summary>
        /// <param name="startTime">The start time.</param>
        /// <param name="endTime">The end time.</param>
        /// <param name="attachmentDirectoryPath">The attachment directory path.</param>
        /// <returns>
        /// The downloaded messages, or null if error occurs
        /// </returns>
        IEnumerable<IMessage> DownloadMessages(DateTime startTime, DateTime endTime, string attachmentDirectoryPath);

        IEnumerable<IMessage> UpdateMessage(IMessage message);

        /// <summary>
        /// Downloads the attachment.
        /// </summary>
        /// <param name="attachment">The attachment.</param>
        /// <returns>True if the attachment is downloaded, false if error occurs</returns>
        bool DownloadAttachment(IAttachment attachment);

        /// <summary>
        /// Sends a new message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// 
        /// <returns>True if operation succeed, otherwise false.</returns>
        bool SendMessage(IMessage message);


        /// <summary>
        /// Replies the message.
        /// </summary>
        /// <param name="original">The original message.</param>
        /// <param name="reply">The reply.</param>
        /// <returns>True if operation succeed, otherwise false.</returns>
        bool ReplyMessage(IMessage original, IMessage reply);

        /// <summary>
        /// Cancels the blocking call in progress.
        /// </summary>
        /// <returns></returns>
        void CancelBlockingCall();

        /// <summary>
        /// Occurs when the operation completed with an error
        /// </summary>
        event PluginErrorEventHandler ErrorOccur;
    }
}
